package com.health.db.dao.user.impl;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.user.IUserCardTypeDao;
import com.health.db.mapper.UserCardTypeMapper;
import com.health.db.model.UserCardType;
import com.health.redis.RedisConstants;


public class UserCardTypeDaoImpl  extends ServiceInterface implements IUserCardTypeDao{

	
	UserCardTypeMapper userCardTypeMapper;

	/**
	 * 卡类型
	 * cardtypeid
	 */
	@Override
	public UserCardType selectByCardTypeId(Long cardtypeid) {
		// TODO Auto-generated method stub
        getRedisOperatiorLogic();
        String key =RedisConstants.UserCardTypeMapper+":cardtypeid:"+cardtypeid;
        
        Object object=null;
        UserCardType userCardType = null;
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object&&!object.equals("")){
        	 userCardType =  (UserCardType) object;
         }else{
        	 userCardType=userCardTypeMapper.selectByCardTypeId(cardtypeid);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, userCardType,  getOrderRedisGroupNo("1"));
             }
         }
        return userCardType;
		
	}

	public UserCardTypeMapper getUserCardTypeMapper() {
		return userCardTypeMapper;
	}

	public void setUserCardTypeMapper(UserCardTypeMapper userCardTypeMapper) {
		this.userCardTypeMapper = userCardTypeMapper;
	}
}
